package com.douqu.game.activity;

import com.bean.core.util.FileUtils;
import com.douqu.game.activity.manager.ActivityCampManager;
import com.douqu.game.core.entity.activity.RankCamp;
import com.douqu.game.core.entity.activity.RankPlayer;
import com.douqu.game.core.factory.ConfigFactory;

import java.io.File;
import java.util.List;

/**
* @Author: Bean
* @Description:
* @Date: 2018-04-16 19:29
*/
public class PrintUtils {

    public static void saveCampActivityRankInfo()
    {
        ActivityCampManager activityCampManager = GameServer.getInstance().getActivityCampManager();

        List<RankPlayer> rankPlayerList = activityCampManager.getRankPlayerList();
        StringBuilder buffer = new StringBuilder();
        if(!rankPlayerList.isEmpty())
        {
            List<RankCamp> rankCampList = activityCampManager.getRankCampList();
            buffer.append("阵营排名: \n");
            for(int i = 0; i < rankCampList.size(); i++)
            {
                buffer.append("No.");
                buffer.append(i+1);
                buffer.append("->[阵营:");
                buffer.append(rankCampList.get(i).getCamp());
                buffer.append(",功勋:");
                buffer.append(rankCampList.get(i).getValue());
                buffer.append("]\n");
            }

            buffer.append("最高击杀: ");
            buffer.append(activityCampManager.getMaxWinCountPlayer().baseInfo());
            buffer.append("\n最高连胜: ");
            buffer.append(activityCampManager.getMaxContinueWinPlayer().baseInfo());
            buffer.append("\n最高功勋: ");
            buffer.append(activityCampManager.getMaxExploitPlayer().baseInfo());
            buffer.append("\n玩家排行: \n");
            buffer.append("排名\t昵称\t功勋\t所属\t\n");

            int i = 0;
            for(RankPlayer rankPlayer : rankPlayerList)
            {
                buffer.append(++i);
                buffer.append("\t");
                buffer.append(rankPlayer.getName());
                buffer.append("\t");
                buffer.append(rankPlayer.getValue());
                buffer.append("\t");
                buffer.append(rankPlayer.getServerName());
                buffer.append("\n");
            }

            File directory = new File(ConfigFactory.LOG_PATH + "camp");
            if(!directory.exists())
                directory.mkdirs();

            File file = new File(directory.getPath()+ "/" + activityCampManager.getIndex() + ".txt");
            FileUtils.writeFile(file.getAbsolutePath(), buffer.toString());

        }
    }
}
